<?php
class Block_Admin_Abiturient_Grid
    extends Block_Core_Grid_Abstract
{
    public function prepareColumns()
    {
        $this->_addColumn(array(
            'type'=>'text',
            'title'=>'Firstname',
            'sort'=>true,
            'index'=>'firstname'
        ));

        $this->_addColumn(array(
            'type'=>'text',
            'title'=>'Lastname',
            'sort'=>true,
            'index'=>'lastname'
        ));

        $this->_addColumn(array(
            'type'=>'date',
            'title'=>'Date of birth',
            'sort'=>true,
            'index'=>'date_narod'
        ));

        $this->_addAction(array(
            'label'   => 'Action',
            'title'   => 'Action Column',
            'options' => array(
                array(
                    'url'   => 'admin/abiturient/view/',
                    'label' => 'View',
                    'index' => 'entity_id',
                    'value' => 'item',
                    'class' => 'ico edit',
                ),
                array(
                    'url'   => 'admin/abiturient/delete/',
                    'label' => 'Delete',
                    'index' => 'entity_id',
                    'value' => 'item',
                    'class' => 'ico del',
                ),
            ),
        ));

        return parent::prepareColumns();
    }

    public function prepareMasaction()
    {
        $params = array(
            'index'    => 'entity_id',
            'var'      => 'items',
            'option'   => array(
                array(
                    'url'    => 'admin/abiturient/delete',
                    'title'  => 'Delete',
                ),
            ),
        );

        $this->_addMasaction($params);

        return parent::prepareMasaction();
    }

    public function prepareCollection()
    {
        $collection = new Model_Abiturient_Resource_Item_Collection();
        $collection->load();

        $this->setCollection($collection);

        return parent::prepareCollection();
    }
}